<?php

/***

LZRoster: A roster for World of Warcraft.
Copyright (C) 2007  Emmanuel Cron

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

***/

class Character
{	
	private $id;
	private $name;
	private $revision;
	private $locale;
	private $faction_en;
	private $race_en;
	private $class_en;
	private $sex_id;
	private $level;
	private $current_experience;
	private $max_experience;
	private $rested_experience;
	private $guild_title;
	private $guild_rank;
	private $time_played;
	private $time_level_played;
	private $timestamp_update;
	
	private $access = array();
	private $professions = array();
	
	function Character($t)
	{
		$this->id = $t['character_id'];
		$this->name = $t['Name'];
		$this->revision = $t['Revision'];
		$this->locale = $t['Locale'];
		$this->faction_en = $t['FactionEn'];
		$this->race_en = $t['RaceEn'];
		$this->class_en = $t['ClassEn'];
		$this->sex_id = $t['SexId'];
		$this->level = $t['Level'];
		$this->current_experience = $t['CurrentExperience'];
		$this->max_experience = $t['MaxExperience'];
		$this->rested_experience = $t['RestedExperience'];
		$this->guild_title = $t['GuildTitle'];
		$this->guild_rank = $t['GuildRank'];
		$this->time_played = $t['TimePlayed'];
		$this->time_level_played = $t['TimeLevelPlayed'];
		$this->timestamp_update = $t['timestampUpdate'];
		
		if ( array_key_exists('Dungeon', $t) and $t['Dungeon'] != null )
		{
			array_push($this->access, $t['Dungeon']);
		}
		
		if ( array_key_exists('ProfessionName', $t) and $t['ProfessionName'] != null )
		{
			array_push($this->professions, $t['ProfessionName']);
		}
	}
	
	function GetId()
	{
		return $this->id;
	}
	
	function GetName()
	{
		return $this->name;
	}
	
	function GetRace()
	{
		return $this->race_en;
	}
	
	function GetClass()
	{
		return $this->class_en;
	}
	
	function GetSexId()
	{
		return $this->sex_id;
	}
	
	function AddProfession($profession)
	{
		array_push($this->professions, $profession);
	}
	
	function AddDungeon($dungeon)
	{
		array_push($this->access, $dungeon);
	}
	
	function GetProfessions()
	{
		return $this->professions;
	}
	
	function GetGuildRank()
	{
		return $this->guild_rank;
	}
	
	function GetGuildTitle()
	{
		return $this->guild_title;
	}
	
	function GetLevel()
	{
		return $this->level;
	}
	
	function GetRevision()
	{
		return $this->revision;
	}
	
	function GetLastUpdate()
	{
		return $this->timestamp_update;
	}
	
	function GetTimePlayed()
	{
		return $this->time_played;
	}
	
	function GetTimeLevelPlayed()
	{
		return $this->time_level_played;
	}
	
	function GetCurrentExperience()
	{
		return $this->current_experience;
	}
	
	function GetMaxExperience()
	{
		return $this->max_experience;
	}
	
	function GetRestedExperience()
	{
		return $this->rested_experience;
	}
	
	function GetAccess()
	{
		return $this->access;
	}
	
	function HasDungeonAccess($dungeon)
	{
		if ( in_array($dungeon, $this->access) )
		{
			return true;
		}
		else
		{
			return false;	
		}
	}
}

?>